<template>
	<view class="dachu">
		<!-- #ifdef H5 -->
		
		<Tou></Tou>
		<!-- #endif -->
	<scroll-view scroll-y="true" class="main"  @scrolltolower="lowerBottom">
	<biaotou @tiao="tiao"></biaotou>
	<!-- nr -->
	<view class="nr">
		<one v-if="FileList==0" :shuju="list1"></one>
		<tow v-else-if="FileList==1" :shuju='list2'></tow>
		<three v-else></three>
		<view class="loading" v-show="show">
			加载中...
		</view>
		<view class="loading" v-show="di">
			没有数据了
		</view>
	</view>
	</scroll-view>
	</view>
</template>

<script>
	import Tou from "@/common/nav-tar.vue"
	import biaotou from "@/components/dachu/biaotou.vue"
import { apis } from "@/http/api.js"
	import one from "@/pages/dachu/one.vue"
	import tow from "@/pages/dachu/tow.vue"
	import three from "@/pages/dachu/three.vue"
	export default {
		data() {
			return {
				FileList:0,
				list1:[],
				list2:[],
				yema:1,
				yema1:1,
				show:true,
				di:false,
			}
		},
	onLoad() {
		this.huoqu()
	},
		methods: {
			tiao(val){
			this.FileList=val
			console.log(this.FileList);
				
			},
			huoqu(){
			apis.dachuzhibo().then((res)=>{
				this.list1=res[1].data.course.data
				// console.log(this.list1);
				
			})	
			apis.dachuliebiao(this.yema1).then((res)=>{
				this.list2=res[1].data.data
				console.log(res[1].data.data);
			})
			},
			lowerBottom(){
				
				this.show=true
				if (this.FileList==0) {
					this.yema++
					apis.dachushuju(this.yema).then((res)=>{
						if (res[1].data.course.data.length==0) {
							this.show=false
							this.di=true
							
						} else{
								this.list1=[...this.list1,...res[1].data.course.data]
						this.show=false
						}
						
					
						
					})
				} else if(this.FileList==1){
					this.yema1++
					apis.dachuliebiao(this.yema1).then((res)=>{
						if (res[1].data.data.length==0) {
							this.show=false
							this.di=true
							console.log('到底了');
						} else{
								this.list2=[...this.list2,...res[1].data.data]
						this.show=false
						}
					
					})
				}else{
					this.di=true
					this.show=false
				}
			
				
			}
		},
		components:{
			Tou,
			one,
			tow,
			three,
			biaotou,
		}
	}
</script>

<style lang="scss" scoped>
	.dachu{
		background-color: #eee;
	}
.nr{
	
	padding: 30rpx 30rpx ;
	.loading{
		text-align: center;
		margin: 10rpx 0;
		font-size: 24rpx;
		    color: #a1afb5;
	}
}
</style>
